home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload Trio 2
/
Shareware Overload Trio Volume 2 (Chestnut CD-ROM).ISO
/
dir42
/
doslbs.zip
/
DOSLIB04.CLA
< prev
next >
Wrap
Text File
|
1994-02-21
|
14KB
|
258 lines
MEMBER('DOSLIB')
Map
Prt:Import_Comma(String,*String[],String,String)
.
OMIT('╝')
╔════════════════════════════════════════════════════════════════════════════╗
║ File_Printer_Setup - !Generated Procedure ║
╚════════════════════════════════════════════════════════════════════════════╝
Printer_Setup Procedure(Printer:Controls,Control:File,Printer:Initialise)
Printer_Controls Group
Prt:Destination String(6)
Prt:Filespec String(64)
Prt:PrinterName String(30)
Prt:Control_BF String(30)
Prt:Control_AFT String(30)
Prt:Lines_Page Short(60)
.
INILine String(64)
INIVariables String(30),Dim(8)
SCREEN SCREEN(19,40),PRE(SCR),SHADOW,FALL,CUA,COLOR(112)
!style=D:\CLARION\DEVELOP\DOSLIB\CLARION.STY
ROW(1,2) PAINT(1,13),COLOR(2)
ROW(1,26) PAINT(1,14),COLOR(2)
ROW(4,4) PAINT(7,1),COLOR(10)
ROW(4,13) PAINT(5,10),COLOR(10)
ROW(4,31) PAINT(6,7),COLOR(10)
ROW(8,5) PAINT(1,8),COLOR(10)
ROW(8,23) PAINT(2,8),COLOR(10)
ROW(9,15) PAINT(1,8),COLOR(10)
ROW(10,13) PAINT(1,1),COLOR(10)
ROW(10,35) PAINT(1,3),COLOR(10)
ROW(1,15) STRING('Print Setup'),COLOR(2)
ROW(10,14) STRING(':'),COLOR(15)
ROW(19,1) STRING('█▄{38}█'),COLOR(3)
REPEAT(18)
ROW(1,1) STRING('█'),COLOR(3)
ROW(1,40) STRING('█'),COLOR(3)
.
ROW(3,4) PROMPT('&Output to:'),COLOR(4,5,40,6,7)
OPTION,USE(Prt:Destination),IMM
ROW(4,5) RADIO('LPT1'),OVR,COLOR(15,16,37,41,42)
ROW(5,5) RADIO('LPT2'),OVR,COLOR(15,16,37,41,42)
ROW(6,5) RADIO('LPT3'),OVR,COLOR(15,16,37,41,42)
ROW(7,5) RADIO('LPT4'),OVR,COLOR(15,16,37,41,42)
ROW(4,23) RADIO('COM1'),OVR,COLOR(15,16,37,41,42)
ROW(5,23) RADIO('COM2'),OVR,COLOR(15,16,37,41,42)
ROW(6,23) RADIO('COM3'),OVR,COLOR(15,16,37,41,42)
ROW(7,23) RADIO('COM4'),OVR,COLOR(15,16,37,41,42)
ROW(9,5) RADIO('&SCREEN'),COLOR(15,16,37,41,42)
ROW(10,5) RADIO('&FILE'),OVR,COLOR(15,16,37,41,42)
.
COL(15) ENTRY(@s20),USE(Prt:Filespec),OVR,COLOR(15,16,37)
ROW(12,4) PROMPT('Li&nes Per Page :'),COLOR(4,5,40,6,7)
COL(21) ENTRY(@n_2),USE(Prt:Lines_Page),INS,COLOR(8,9,38)
ROW(13,4) PROMPT('Control &Before :'),COLOR(4,5,40,6,7)
COL(21) ENTRY(@s15),USE(Prt:Control_BF),OVR,COLOR(8,9,38)
ROW(14,4) PROMPT('Control &After :'),COLOR(4,5,40,6,7)
COL(21) ENTRY(@s15),USE(Prt:Control_AFT),OVR,COLOR(8,9,38)
ROW(15,4) PROMPT('Printer &Name :'),COLOR(4,5,40,6,7)
COL(21) ENTRY(@s15),USE(Prt:PrinterName),OVR,COLOR(8,9,38)
COL(37) BUTTON(''),KEY(AltF),USE(?Find_Printer),COLOR(17,18,39,19,20)
ROW(17,4) BUTTON(' &Ok |'),SHADOW,KEY(EnterKey),USE(?Ok),COLOR(17,18,39,19,20)
COL(14) BUTTON(' &Cancel |'),SHADOW,KEY(EscKey),USE(?Cancel),COLOR(17,18,39,19,20)
COL(26) BUTTON(' &Defaults '),SHADOW,USE(?Defaults),COLOR(17,18,39,19,20)
.
CODE
If ~Omitted(3) then
Printer_Controls = Printer:Controls
Do ReadIniFile
Printer:Controls = Printer_Controls
Return
.
OPEN(Screen)
Printer_Controls = Printer:Controls
Do Enable_File
Display
LOOP
ACCEPT !Accept input
CASE FIELD()
OF ?Prt:Destination
Do Enable_File
OF ?Prt:Filespec
OF ?Prt:Lines_Page
OF ?Prt:Control_BF
OF ?Prt:Control_AFT
OF ?Prt:PrinterName
OF ?Find_Printer
Prt:PrinterName = Select_Printer(Prt:PrinterName,Control:File)
Select(?Prt:PrinterName)
OF ?Ok
Break
OF ?Cancel
Prt:FileSpec = 'CANCEL'
Break
Of ?Defaults
Do ReadINIFile
Do Enable_File
Display
. .
Printer:Controls = Printer_Controls
Return
Enable_File Routine
Case Clip(Prt:Destination)
Of 'LPT1' ; Disable(?Prt:FileSpec); Prt:FileSpec = 'LPT1'
Of 'LPT2' ; Disable(?Prt:FileSpec); Prt:FileSpec = 'LPT2'
Of 'LPT3' ; Disable(?Prt:FileSpec); Prt:FileSpec = 'LPT3'
Of 'LPT4' ; Disable(?Prt:FileSpec); Prt:FileSpec = 'LPT4'
Of 'COM1' ; Disable(?Prt:FileSpec); Prt:FileSpec = 'COM1'
Of 'COM2' ; Disable(?Prt:FileSpec); Prt:FileSpec = 'COM2'
Of 'COM3' ; Disable(?Prt:FileSpec); Prt:FileSpec = 'COM3'
Of 'COM4' ; Disable(?Prt:FileSpec); Prt:FileSpec = 'COM4'
Of 'SCREEN' ; Disable(?Prt:FileSpec); Prt:FileSpec = 'SCREEN'
Of 'FILE' ; Enable (?Prt:FileSpec);
.
Exit
ReadINIFile Routine
IniLine = Command('CLAPRINTDEVICE',0)
Prt:Import_Comma(IniLine,IniVariables[],'<39>',',')
Prt:Destination = INIVariables[1]
Prt:Lines_Page = INIVariables[2]
Prt:Control_BF = INIVariables[7]
Prt:Control_AFT = INIVariables[8]
Prt:PrinterName = Command('CLAPRINTERNAME',0)
Exit
Prt:Import_Comma PROCEDURE(Data:Record,Data:Table,Delimiter:Str,Delimiter:Fld)
!
! ┌─────────────────────────────────────────────────────────────────────────┐
! │ Data Extract Procedure 1 - Comma Delimited Fields │
! ├─────────────────────────────────────────────────────────────────────────┤
! │ Procedure Name.: EXT_COMMA_FIELDS │
! │ Description....: Extracts individual fields from a Comma Delimited File │
! │ Parameters.....: Data:Table - Table to hold the fields after extraction│
! │ Data:Record - Record containing delimited fields │
! │ │
! ├─────────────────────────────────────────────────────────────────────────┤
! │ Algorithm: │
! │ │
! │ 1. Examine the first character of the record to determine the following │
! │ (i) If it is a Quote, then ignore (Processing Loop will pick it up)│
! │ (ii) If it is a Comma, then assume a empty field and process it │
! │ (iii) Otherwise assume in field processing for numeric value │
! │ │
! │ 2. Loop until end of record │
! │ (i) Examine the character at position (x) │
! │ (ii) If it is a Quote and Not In-Field Processing, then Skip to │
! │ next quote character │
! │ (iii) If it is a Quote and In-Field processing, then add the field │
! │ to the table │
! │ (iv) If it is a Comma and the next character is a Quote, then │
! │ ignore it │
! │ (v) If it is a Comma and the next character is not a Quote, then │
! │ assume numeric processing │
! │ │
! │ 3. After end of record, add the last field to the data table │
! └─────────────────────────────────────────────────────────────────────────┘
!
! --------------------------------------------------------------------------
! Local Processing Variables
! --------------------------------------------------------------------------
!
Pointers Group,Pre(Ptr) ! Record Processing Pointers
Current_Field Byte ! Current Processing Field #
Current_Character Short ! Processing Character (X)
Last_Character Short ! Last Pointer (Y)
Start_Position Short ! Starting Position for Loop
Last_Position Short ! Last Character to Process
In_Field Byte ! Field Type Processing
. ! End of Group
Flg:Not_In_Field Equate(0) ! Not in a Field
Flg:In_String Equate(1) ! Processing a String Field
Flg:In_Numeric Equate(2) ! Processing a Numeric Field
!
! --------------------------------------------------------------------------
! Code Section
! --------------------------------------------------------------------------
!
CODE
Ptr:Current_Field = 0
Ptr:Current_Character = 0
Ptr:Last_Character = 0
Ptr:Start_Position = 0
Ptr:Last_Position = Len(Clip(Data:Record))
Ptr:In_Field = Flg:Not_In_Field
Clear(Data:Table[])
!
! ----------------------------------------------------------
! 1. Determine the Starting Position for the Parser
! ----------------------------------------------------------
!
If Data:Record[1] = Delimiter:Fld or |
Data:Record[1] <> Delimiter:Str then
Ptr:In_Field = Flg:In_Numeric
Do Get_Data_Field
Else
Ptr:Current_Character = 1
.
!
! ----------------------------------------------------------
! 2. Process the Fields
! ----------------------------------------------------------
!
Loop Until Ptr:Current_Character > Ptr:Last_Position
If Data:Record[Ptr:Current_Character] = Delimiter:Str and |
Ptr:In_Field = Flg:Not_in_Field then
Ptr:In_Field = Flg:In_String
Do Get_Data_Field
Elsif Data:Record[Ptr:Current_Character] = Delimiter:Str and |
Ptr:In_Field <> Flg:Not_in_Field then
Ptr:In_Field = Flg:Not_in_Field
Ptr:Current_Character += 1
Elsif Data:Record[Ptr:Current_Character] = Delimiter:Fld and |
Data:Record[Ptr:Current_Character+1] = Delimiter:Str then
Ptr:In_Field = Flg:Not_in_Field
Ptr:Current_Character += 1
Elsif Data:Record[Ptr:Current_Character] = Delimiter:Fld and |
Data:Record[Ptr:Current_Character+1] <> Delimiter:Str then
Ptr:In_Field = Flg:In_Numeric
Do Get_Data_Field
Else
Break
. .
Return
!
! ┌────────────────────────────────────────────────────────────────────────┐
! │ Subroutine : Get_Data_Field │
! │ Description: Gets the Data from the Record and Adds to the Table │
! └────────────────────────────────────────────────────────────────────────┘
!
Get_Data_Field Routine
Ptr:Last_Character = Ptr:Current_Character + 1
Execute Ptr:In_Field
Ptr:Current_Character = Instring(Delimiter:Str,Data:Record,1,Ptr:Last_Character)
Ptr:Current_Character = Instring(Delimiter:Fld,Data:Record,1,Ptr:Last_Character)
.
If Ptr:Current_Character = 0 then Ptr:Current_Character = Ptr:Last_Position + 1.
Ptr:Current_Field += 1
If Ptr:Current_Field <= Maximum(Data:Table,1) then
Data:Table[Ptr:Current_Field] = Sub(Data:Record,Ptr:Last_Character,(Ptr:Current_Character - Ptr:Last_Character))
.
Exit